package com.codef.sharp.rbac.controller;

import java.util.Arrays;
import java.util.Map;

import com.codef.sharp.common.core.response.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.codef.sharp.rbac.entity.GroupRoleEntity;
import com.codef.sharp.rbac.service.GroupRoleService;


/**
 * 组角色关联表控制层
 *
 * @author zhanrf
 * @date 2022-02-12 20:06:41
 */
@RestController
@RequestMapping("rbac/grouprole")
public class GroupRoleController {
    @Autowired
    private GroupRoleService groupRoleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public ResponseEntity list(@RequestParam Map<String, Object> params){
        return ResponseEntity.success();
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public ResponseEntity<GroupRoleEntity> info(@PathVariable("id") Long id){
		GroupRoleEntity groupRole = groupRoleService.getById(id);
        return ResponseEntity.success(groupRole);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public ResponseEntity<Void> save(@RequestBody GroupRoleEntity groupRole){
		groupRoleService.save(groupRole);
        return ResponseEntity.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public ResponseEntity<Void> update(@RequestBody GroupRoleEntity groupRole){
		groupRoleService.updateById(groupRole);
        return ResponseEntity.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public ResponseEntity<Void> delete(@RequestBody Long[] ids){
		groupRoleService.removeByIds(Arrays.asList(ids));
        return ResponseEntity.success();
    }

}
